package client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.*;
import com.google.gwt.user.client.Element;

import java.util.Collection;
import java.util.Iterator;

/**
 * Created by IntelliJ IDEA.
 * User: Wouter Wendelen
 * Date: 31-aug-2007
 * Time: 20:47:19
 */
public class CssField implements EntryPoint {
    public void onModuleLoad() {

        CssManager manager = CssManager.getInstance();
        Collection areas = ConfigHelper.getAllAreas();
        for (Iterator iterator = areas.iterator(); iterator.hasNext();) {
            final String areaId = (String) iterator.next();
            RichTextArea richTextArea = new RichTextArea();
            richTextArea.setTitle(areaId);
            //disableContextMenu(richTextArea.getElement());
            TextArea textArea = new TextArea();
            richTextArea.setWidth(ConfigHelper.getWidth(areaId));
            richTextArea.setHeight(ConfigHelper.getHeight(areaId));
            textArea.setWidth(ConfigHelper.getWidth(areaId));
            textArea.setHeight(ConfigHelper.getHeight(areaId));
            VerticalPanel panel = new VerticalPanel();
            CssController controller = new CssController(richTextArea, textArea);
            panel.add(richTextArea);
            panel.add(textArea);
            RootPanel.get(areaId).add(panel);
            //RootPanel.get(areaId).add(richTextArea);
            manager.manage(areaId, controller);
        }
        manager.boot();
    }

    /**
      * Disables the browsers default context menu for the specified element.
      *
      * @param elem the element whos context menu will be disabled
      */
     public static native void disableContextMenu(Element elem) /*-{
        elem.oncontextmenu=function() {  return false};
      }-*/;

}